{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=center>数据可视化</h1>\n",
    "<h3 align=center>中国的天气数据</h3>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 姓名：杨科棪\n",
    "## 学号：202152320108\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "气候变化是一个世界难题。在这个练习中，我们将关注中国的2004年至2015年的天气数据。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 一: Python中的地图\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Python中的绘图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "pyecharts是一个十分流行的python包，能够实现酷炫的交互式图表."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 世界地图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'world':'https://assets.pyecharts.org/assets/maps/world'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"f9a2ab709d274912bc954ce703838781\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'world'], function(echarts) {\n",
       "                var chart_f9a2ab709d274912bc954ce703838781 = echarts.init(\n",
       "                    document.getElementById('f9a2ab709d274912bc954ce703838781'), 'white', {renderer: 'canvas'});\n",
       "                var option_f9a2ab709d274912bc954ce703838781 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"geo\": {\n",
       "        \"map\": \"world\",\n",
       "        \"roam\": true,\n",
       "        \"aspectScale\": 0.75,\n",
       "        \"nameProperty\": \"name\",\n",
       "        \"selectedMode\": false,\n",
       "        \"emphasis\": {}\n",
       "    }\n",
       "};\n",
       "                chart_f9a2ab709d274912bc954ce703838781.setOption(option_f9a2ab709d274912bc954ce703838781);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7fe134f0b208>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Geo\n",
    "geo = Geo()\n",
    "geo.add_schema(maptype=\"world\")\n",
    "geo.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 画出一个位置（经度、纬度）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "让我们绘制北京!\n",
    "\n",
    "(39.9042° N, 116.4074° E)\n",
    "\n",
    "纬度: 39.9042  \n",
    "经度: 116.4074"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"34dec818a3a941f68973a9bb91cc9ad2\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_34dec818a3a941f68973a9bb91cc9ad2 = echarts.init(\n",
       "                    document.getElementById('34dec818a3a941f68973a9bb91cc9ad2'), 'white', {renderer: 'canvas'});\n",
       "                var option_34dec818a3a941f68973a9bb91cc9ad2 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"coordinateSystem\": \"geo\",\n",
       "            \"symbolSize\": 12,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"Beijing\",\n",
       "                    \"value\": [\n",
       "                        116.4074,\n",
       "                        39.9042,\n",
       "                        2\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"geo\": {\n",
       "        \"map\": \"china\",\n",
       "        \"roam\": true,\n",
       "        \"aspectScale\": 0.75,\n",
       "        \"nameProperty\": \"name\",\n",
       "        \"selectedMode\": false,\n",
       "        \"emphasis\": {}\n",
       "    }\n",
       "};\n",
       "                chart_34dec818a3a941f68973a9bb91cc9ad2.setOption(option_34dec818a3a941f68973a9bb91cc9ad2);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7fe134f6fbe0>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Beijing\n",
    "lat = 39.9042\n",
    "lon = 116.4074\n",
    "\n",
    "from pyecharts.charts import Geo\n",
    "from pyecharts import options as opts\n",
    "\n",
    "geo = Geo()\n",
    "geo.add_schema(maptype=\"china\")\n",
    "geo.add_coordinate('Beijing', lon, lat)\n",
    "geo.add(\"\", [('Beijing', 2)])\n",
    "geo.set_series_opts(label_opts = opts.LabelOpts(is_show=False))\n",
    "geo.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 尝试画出上海!\n",
    "你能自己得到上海的经度和纬度吗？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"9dfebd0f38544f16a36057e68d14051c\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_9dfebd0f38544f16a36057e68d14051c = echarts.init(\n",
       "                    document.getElementById('9dfebd0f38544f16a36057e68d14051c'), 'white', {renderer: 'canvas'});\n",
       "                var option_9dfebd0f38544f16a36057e68d14051c = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"coordinateSystem\": \"geo\",\n",
       "            \"symbolSize\": 12,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"Shanghai\",\n",
       "                    \"value\": [\n",
       "                        121.4737,\n",
       "                        31.9042,\n",
       "                        2\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"geo\": {\n",
       "        \"map\": \"china\",\n",
       "        \"roam\": true,\n",
       "        \"aspectScale\": 0.75,\n",
       "        \"nameProperty\": \"name\",\n",
       "        \"selectedMode\": false,\n",
       "        \"emphasis\": {}\n",
       "    }\n",
       "};\n",
       "                chart_9dfebd0f38544f16a36057e68d14051c.setOption(option_9dfebd0f38544f16a36057e68d14051c);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7fe134eda908>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Shanghai\n",
    "lat = 31.9042\n",
    "lon = 121.4737\n",
    "\n",
    "from pyecharts.charts import Geo\n",
    "from pyecharts import options as opts\n",
    "\n",
    "geo = Geo()\n",
    "geo.add_schema(maptype=\"china\")\n",
    "geo.add_coordinate('Shanghai', lon, lat)\n",
    "geo.add(\"\", [('Shanghai', 2)])\n",
    "geo.set_series_opts(label_opts = opts.LabelOpts(is_show=False))\n",
    "geo.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 绘制文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"1e4f7d8c280e43ffad0e81b9cc7c8cb7\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_1e4f7d8c280e43ffad0e81b9cc7c8cb7 = echarts.init(\n",
       "                    document.getElementById('1e4f7d8c280e43ffad0e81b9cc7c8cb7'), 'white', {renderer: 'canvas'});\n",
       "                var option_1e4f7d8c280e43ffad0e81b9cc7c8cb7 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"coordinateSystem\": \"geo\",\n",
       "            \"symbolSize\": 12,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"Beijing\",\n",
       "                    \"value\": [\n",
       "                        116.4074,\n",
       "                        39.9042,\n",
       "                        2\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Shanghai\",\n",
       "                    \"value\": [\n",
       "                        121.4737,\n",
       "                        31.9042,\n",
       "                        2\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 20,\n",
       "                \"formatter\": \"{b}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"geo\": {\n",
       "        \"map\": \"china\",\n",
       "        \"roam\": true,\n",
       "        \"aspectScale\": 0.75,\n",
       "        \"nameProperty\": \"name\",\n",
       "        \"selectedMode\": false,\n",
       "        \"emphasis\": {}\n",
       "    }\n",
       "};\n",
       "                chart_1e4f7d8c280e43ffad0e81b9cc7c8cb7.setOption(option_1e4f7d8c280e43ffad0e81b9cc7c8cb7);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7fe134f0b828>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Beijing\n",
    "#Shanghai\n",
    "lat1 = 39.9042\n",
    "lon1 = 116.4074\n",
    "lat2 = 31.9042\n",
    "lon2 = 121.4737\n",
    "\n",
    "from pyecharts.charts import Geo\n",
    "from pyecharts import options as opts\n",
    "\n",
    "geo = Geo()\n",
    "geo.add_schema(maptype=\"china\")\n",
    "geo.add_coordinate('Beijing', lon1, lat1)\n",
    "geo.add_coordinate('Shanghai', lon2, lat2)\n",
    "geo.add(\"\", [('Beijing', 2), ('Shanghai', 2)])\n",
    "geo.set_series_opts(label_opts = opts.LabelOpts(is_show=True, font_size=20, formatter='{b}'))\n",
    "geo.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 二: 根据中国的天气数据进行绘制"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据源\n",
    "\n",
    "数据可以从[国家海洋和大气治理署](http://www.ncdc.noaa.gov/data-access/quick-links)获取."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 了解气候数据\n",
    "\n",
    "我们有中国2005年至2015年的31个气象站的数据\n",
    "\n",
    "这里有两个数据文件：`data_weather.csv` 包含每个气象站(**`ID`**)提供的水和温度数据。`stations.csv`包含了每个气象站的信息.\n",
    "\n",
    "### `data_weather.csv`:\n",
    "它包含了从2005年到2015年中国31个气象站的日常测量数据。\n",
    "\n",
    "- **ID**: 站点识别码. \n",
    "- **YEAR**: 观测年份 (YYYY)\n",
    "- **MONTH**: 观测月份 (MM)\n",
    "- **DAY**: 观测日 (DD)\n",
    "- **ELEMENT**: 元素类型.一共分四种:\n",
    "    - _PRCP_: 降水 (毫米mm)\n",
    "    - _TAVG_: 平均温度 (摄氏度Celsius)\n",
    "    - _TMIN_: 最低温度 (摄氏度Celsius)\n",
    "    - _TMAX_: 最高问题 (摄氏度Celsius)\n",
    "- **VALUE**: 上述测量元素的值\n",
    "\n",
    "<hr>\n",
    "\n",
    "### `stations.csv`:\n",
    "站点信息包括\n",
    "- **ID**: 站点识别码.\n",
    "- **LATITUDE**: 站点纬度 \n",
    "- **LONGITUDE**: 站点经度\n",
    "- **ELEVATION**: 站点海拔 (单位米)\n",
    "- **NAME**: 站点名"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 载入依赖库"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果你跳过了第一部分，记得再次载入库："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "#增加图大小\n",
    "from pylab import rcParams\n",
    "rcParams['figure.figsize'] = (14,10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 加载 data_weather.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>MONTH</th>\n",
       "      <th>DAY</th>\n",
       "      <th>ELEMENT</th>\n",
       "      <th>VALUE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>TMAX</td>\n",
       "      <td>-13.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>TMIN</td>\n",
       "      <td>-24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>PRCP</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>TAVG</td>\n",
       "      <td>-19.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>TMAX</td>\n",
       "      <td>-6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>TMIN</td>\n",
       "      <td>-16.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>PRCP</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>TAVG</td>\n",
       "      <td>-10.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>TMAX</td>\n",
       "      <td>-7.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>TMIN</td>\n",
       "      <td>-15.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            ID  YEAR  MONTH  DAY ELEMENT  VALUE\n",
       "0  CHM00050953  2005      1    1    TMAX  -13.0\n",
       "1  CHM00050953  2005      1    1    TMIN  -24.0\n",
       "2  CHM00050953  2005      1    1    PRCP    0.0\n",
       "3  CHM00050953  2005      1    1    TAVG  -19.0\n",
       "4  CHM00050953  2005      1    2    TMAX   -6.0\n",
       "5  CHM00050953  2005      1    2    TMIN  -16.3\n",
       "6  CHM00050953  2005      1    2    PRCP    0.0\n",
       "7  CHM00050953  2005      1    2    TAVG  -10.5\n",
       "8  CHM00050953  2005      1    3    TMAX   -7.4\n",
       "9  CHM00050953  2005      1    3    TMIN  -15.5"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv(\"data_weather.csv\")\n",
    "df.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 加载 stations.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>LATITUDE</th>\n",
       "      <th>LONGITUDE</th>\n",
       "      <th>ELEVATION</th>\n",
       "      <th>NAME</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>CHM00045004</td>\n",
       "      <td>22.333</td>\n",
       "      <td>114.167</td>\n",
       "      <td>26</td>\n",
       "      <td>KING'S_PARK</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CHM00045005</td>\n",
       "      <td>22.300</td>\n",
       "      <td>114.167</td>\n",
       "      <td>62</td>\n",
       "      <td>HONG KONG_KONG_OBSERVATORY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CHM00050353</td>\n",
       "      <td>51.717</td>\n",
       "      <td>126.650</td>\n",
       "      <td>179</td>\n",
       "      <td>HUMA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>CHM00050434</td>\n",
       "      <td>50.450</td>\n",
       "      <td>121.700</td>\n",
       "      <td>733</td>\n",
       "      <td>TULIHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CHM00050527</td>\n",
       "      <td>49.250</td>\n",
       "      <td>119.700</td>\n",
       "      <td>650</td>\n",
       "      <td>HAILAR_GSN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>CHM00050557</td>\n",
       "      <td>49.167</td>\n",
       "      <td>125.233</td>\n",
       "      <td>243</td>\n",
       "      <td>NENJIANG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>CHM00050564</td>\n",
       "      <td>49.433</td>\n",
       "      <td>127.350</td>\n",
       "      <td>235</td>\n",
       "      <td>SUNWU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>CHM00050632</td>\n",
       "      <td>48.767</td>\n",
       "      <td>121.917</td>\n",
       "      <td>739</td>\n",
       "      <td>BUGT</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>CHM00050658</td>\n",
       "      <td>48.050</td>\n",
       "      <td>125.883</td>\n",
       "      <td>237</td>\n",
       "      <td>KESHAN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>CHM00050727</td>\n",
       "      <td>47.167</td>\n",
       "      <td>119.933</td>\n",
       "      <td>997</td>\n",
       "      <td>ARXAN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            ID  LATITUDE  LONGITUDE  ELEVATION                        NAME\n",
       "0  CHM00045004    22.333    114.167         26                 KING'S_PARK\n",
       "1  CHM00045005    22.300    114.167         62  HONG KONG_KONG_OBSERVATORY\n",
       "2  CHM00050353    51.717    126.650        179                        HUMA\n",
       "3  CHM00050434    50.450    121.700        733                      TULIHE\n",
       "4  CHM00050527    49.250    119.700        650                  HAILAR_GSN\n",
       "5  CHM00050557    49.167    125.233        243                    NENJIANG\n",
       "6  CHM00050564    49.433    127.350        235                       SUNWU\n",
       "7  CHM00050632    48.767    121.917        739                        BUGT\n",
       "8  CHM00050658    48.050    125.883        237                      KESHAN\n",
       "9  CHM00050727    47.167    119.933        997                       ARXAN"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stations = pd.read_csv(\"stations.csv\")\n",
    "stations.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 合并 `df` 和 `stations`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "凭借列`ID`将两个数据集合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>MONTH</th>\n",
       "      <th>DAY</th>\n",
       "      <th>ELEMENT</th>\n",
       "      <th>VALUE</th>\n",
       "      <th>LATITUDE</th>\n",
       "      <th>LONGITUDE</th>\n",
       "      <th>ELEVATION</th>\n",
       "      <th>NAME</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>TMAX</td>\n",
       "      <td>-13.0</td>\n",
       "      <td>45.75</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143</td>\n",
       "      <td>HARBIN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>TMIN</td>\n",
       "      <td>-24.0</td>\n",
       "      <td>45.75</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143</td>\n",
       "      <td>HARBIN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>PRCP</td>\n",
       "      <td>0.0</td>\n",
       "      <td>45.75</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143</td>\n",
       "      <td>HARBIN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>TAVG</td>\n",
       "      <td>-19.0</td>\n",
       "      <td>45.75</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143</td>\n",
       "      <td>HARBIN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CHM00050953</td>\n",
       "      <td>2005</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>TMAX</td>\n",
       "      <td>-6.0</td>\n",
       "      <td>45.75</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143</td>\n",
       "      <td>HARBIN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            ID  YEAR  MONTH  DAY ELEMENT  VALUE  LATITUDE  LONGITUDE  \\\n",
       "0  CHM00050953  2005      1    1    TMAX  -13.0     45.75    126.767   \n",
       "1  CHM00050953  2005      1    1    TMIN  -24.0     45.75    126.767   \n",
       "2  CHM00050953  2005      1    1    PRCP    0.0     45.75    126.767   \n",
       "3  CHM00050953  2005      1    1    TAVG  -19.0     45.75    126.767   \n",
       "4  CHM00050953  2005      1    2    TMAX   -6.0     45.75    126.767   \n",
       "\n",
       "   ELEVATION    NAME  \n",
       "0        143  HARBIN  \n",
       "1        143  HARBIN  \n",
       "2        143  HARBIN  \n",
       "3        143  HARBIN  \n",
       "4        143  HARBIN  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.merge(df, stations, on='ID', how='left')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  每个站点2015年的测得的平均降雨量是多少？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>YEAR</th>\n",
       "      <th>MONTH</th>\n",
       "      <th>DAY</th>\n",
       "      <th>VALUE</th>\n",
       "      <th>LATITUDE</th>\n",
       "      <th>LONGITUDE</th>\n",
       "      <th>ELEVATION</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NAME</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>BEIJING_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>5.050000</td>\n",
       "      <td>15.600000</td>\n",
       "      <td>4.563333</td>\n",
       "      <td>39.933</td>\n",
       "      <td>116.283</td>\n",
       "      <td>55.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>BENXI</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.303371</td>\n",
       "      <td>15.359551</td>\n",
       "      <td>5.904494</td>\n",
       "      <td>41.317</td>\n",
       "      <td>123.783</td>\n",
       "      <td>185.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHANGCHUN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.113924</td>\n",
       "      <td>14.797468</td>\n",
       "      <td>5.591139</td>\n",
       "      <td>43.900</td>\n",
       "      <td>125.217</td>\n",
       "      <td>238.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHONGQING</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.273504</td>\n",
       "      <td>15.393162</td>\n",
       "      <td>6.730769</td>\n",
       "      <td>29.583</td>\n",
       "      <td>106.467</td>\n",
       "      <td>416.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DALIAN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.166667</td>\n",
       "      <td>15.916667</td>\n",
       "      <td>3.523611</td>\n",
       "      <td>38.900</td>\n",
       "      <td>121.633</td>\n",
       "      <td>97.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>FUZHOU</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>3.873950</td>\n",
       "      <td>15.310924</td>\n",
       "      <td>7.430252</td>\n",
       "      <td>26.083</td>\n",
       "      <td>119.283</td>\n",
       "      <td>14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GUANGZHOU_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.482759</td>\n",
       "      <td>15.336207</td>\n",
       "      <td>15.381034</td>\n",
       "      <td>23.217</td>\n",
       "      <td>113.483</td>\n",
       "      <td>71.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HAIKOU_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.702128</td>\n",
       "      <td>14.882979</td>\n",
       "      <td>8.646809</td>\n",
       "      <td>20.000</td>\n",
       "      <td>110.250</td>\n",
       "      <td>24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HANGZHOU</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.200000</td>\n",
       "      <td>15.200000</td>\n",
       "      <td>12.049231</td>\n",
       "      <td>30.233</td>\n",
       "      <td>120.167</td>\n",
       "      <td>43.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HARBIN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.488095</td>\n",
       "      <td>15.380952</td>\n",
       "      <td>4.359524</td>\n",
       "      <td>45.750</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HEFEI</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.561404</td>\n",
       "      <td>16.000000</td>\n",
       "      <td>9.288596</td>\n",
       "      <td>31.867</td>\n",
       "      <td>117.233</td>\n",
       "      <td>36.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>JINAN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.689655</td>\n",
       "      <td>14.793103</td>\n",
       "      <td>5.708621</td>\n",
       "      <td>36.600</td>\n",
       "      <td>117.050</td>\n",
       "      <td>169.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>JINZHOU</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.528302</td>\n",
       "      <td>14.660377</td>\n",
       "      <td>5.079245</td>\n",
       "      <td>41.133</td>\n",
       "      <td>121.117</td>\n",
       "      <td>70.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>KUNMING</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.972973</td>\n",
       "      <td>16.270270</td>\n",
       "      <td>8.771622</td>\n",
       "      <td>25.017</td>\n",
       "      <td>102.683</td>\n",
       "      <td>1892.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NANCHANG_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.147059</td>\n",
       "      <td>14.382353</td>\n",
       "      <td>13.021324</td>\n",
       "      <td>28.600</td>\n",
       "      <td>115.917</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NANJING</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.415929</td>\n",
       "      <td>16.469027</td>\n",
       "      <td>14.614159</td>\n",
       "      <td>31.933</td>\n",
       "      <td>118.900</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NANNING_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.238095</td>\n",
       "      <td>14.780952</td>\n",
       "      <td>5.937143</td>\n",
       "      <td>22.633</td>\n",
       "      <td>108.217</td>\n",
       "      <td>126.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SANYA</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.486111</td>\n",
       "      <td>17.222222</td>\n",
       "      <td>10.168056</td>\n",
       "      <td>18.217</td>\n",
       "      <td>109.583</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHANGHAI_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.275862</td>\n",
       "      <td>16.146552</td>\n",
       "      <td>10.948276</td>\n",
       "      <td>31.400</td>\n",
       "      <td>121.467</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHIJIAZHUANG</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.772727</td>\n",
       "      <td>16.227273</td>\n",
       "      <td>4.422727</td>\n",
       "      <td>38.033</td>\n",
       "      <td>114.417</td>\n",
       "      <td>81.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TAIYUAN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.862069</td>\n",
       "      <td>16.137931</td>\n",
       "      <td>2.920690</td>\n",
       "      <td>37.783</td>\n",
       "      <td>112.550</td>\n",
       "      <td>779.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TIANJIN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.812500</td>\n",
       "      <td>16.770833</td>\n",
       "      <td>5.710417</td>\n",
       "      <td>39.100</td>\n",
       "      <td>117.167</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WUHAN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.136364</td>\n",
       "      <td>15.336364</td>\n",
       "      <td>11.397273</td>\n",
       "      <td>30.600</td>\n",
       "      <td>114.050</td>\n",
       "      <td>34.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WU_LU_MU_QI_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>3.919355</td>\n",
       "      <td>16.532258</td>\n",
       "      <td>5.788710</td>\n",
       "      <td>43.800</td>\n",
       "      <td>87.650</td>\n",
       "      <td>947.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>XIAMEN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.387097</td>\n",
       "      <td>15.387097</td>\n",
       "      <td>6.852688</td>\n",
       "      <td>24.483</td>\n",
       "      <td>118.083</td>\n",
       "      <td>18.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>XICHANG_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>5.434211</td>\n",
       "      <td>16.368421</td>\n",
       "      <td>6.221053</td>\n",
       "      <td>27.900</td>\n",
       "      <td>102.267</td>\n",
       "      <td>1599.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ZHENGZHOU_GSN</th>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.637931</td>\n",
       "      <td>16.327586</td>\n",
       "      <td>7.713793</td>\n",
       "      <td>34.717</td>\n",
       "      <td>113.650</td>\n",
       "      <td>111.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   YEAR     MONTH        DAY      VALUE  LATITUDE  LONGITUDE  \\\n",
       "NAME                                                                           \n",
       "BEIJING_GSN      2015.0  5.050000  15.600000   4.563333    39.933    116.283   \n",
       "BENXI            2015.0  4.303371  15.359551   5.904494    41.317    123.783   \n",
       "CHANGCHUN        2015.0  4.113924  14.797468   5.591139    43.900    125.217   \n",
       "CHONGQING        2015.0  4.273504  15.393162   6.730769    29.583    106.467   \n",
       "DALIAN           2015.0  4.166667  15.916667   3.523611    38.900    121.633   \n",
       "FUZHOU           2015.0  3.873950  15.310924   7.430252    26.083    119.283   \n",
       "GUANGZHOU_GSN    2015.0  4.482759  15.336207  15.381034    23.217    113.483   \n",
       "HAIKOU_GSN       2015.0  4.702128  14.882979   8.646809    20.000    110.250   \n",
       "HANGZHOU         2015.0  4.200000  15.200000  12.049231    30.233    120.167   \n",
       "HARBIN           2015.0  4.488095  15.380952   4.359524    45.750    126.767   \n",
       "HEFEI            2015.0  4.561404  16.000000   9.288596    31.867    117.233   \n",
       "JINAN            2015.0  4.689655  14.793103   5.708621    36.600    117.050   \n",
       "JINZHOU          2015.0  4.528302  14.660377   5.079245    41.133    121.117   \n",
       "KUNMING          2015.0  4.972973  16.270270   8.771622    25.017    102.683   \n",
       "NANCHANG_GSN     2015.0  4.147059  14.382353  13.021324    28.600    115.917   \n",
       "NANJING          2015.0  4.415929  16.469027  14.614159    31.933    118.900   \n",
       "NANNING_GSN      2015.0  4.238095  14.780952   5.937143    22.633    108.217   \n",
       "SANYA            2015.0  4.486111  17.222222  10.168056    18.217    109.583   \n",
       "SHANGHAI_GSN     2015.0  4.275862  16.146552  10.948276    31.400    121.467   \n",
       "SHIJIAZHUANG     2015.0  4.772727  16.227273   4.422727    38.033    114.417   \n",
       "TAIYUAN          2015.0  4.862069  16.137931   2.920690    37.783    112.550   \n",
       "TIANJIN          2015.0  4.812500  16.770833   5.710417    39.100    117.167   \n",
       "WUHAN            2015.0  4.136364  15.336364  11.397273    30.600    114.050   \n",
       "WU_LU_MU_QI_GSN  2015.0  3.919355  16.532258   5.788710    43.800     87.650   \n",
       "XIAMEN           2015.0  4.387097  15.387097   6.852688    24.483    118.083   \n",
       "XICHANG_GSN      2015.0  5.434211  16.368421   6.221053    27.900    102.267   \n",
       "ZHENGZHOU_GSN    2015.0  4.637931  16.327586   7.713793    34.717    113.650   \n",
       "\n",
       "                 ELEVATION  \n",
       "NAME                        \n",
       "BEIJING_GSN           55.0  \n",
       "BENXI                185.0  \n",
       "CHANGCHUN            238.0  \n",
       "CHONGQING            416.0  \n",
       "DALIAN                97.0  \n",
       "FUZHOU                14.0  \n",
       "GUANGZHOU_GSN         71.0  \n",
       "HAIKOU_GSN            24.0  \n",
       "HANGZHOU              43.0  \n",
       "HARBIN               143.0  \n",
       "HEFEI                 36.0  \n",
       "JINAN                169.0  \n",
       "JINZHOU               70.0  \n",
       "KUNMING             1892.0  \n",
       "NANCHANG_GSN          50.0  \n",
       "NANJING               15.0  \n",
       "NANNING_GSN          126.0  \n",
       "SANYA                  7.0  \n",
       "SHANGHAI_GSN           4.0  \n",
       "SHIJIAZHUANG          81.0  \n",
       "TAIYUAN              779.0  \n",
       "TIANJIN                5.0  \n",
       "WUHAN                 34.0  \n",
       "WU_LU_MU_QI_GSN      947.0  \n",
       "XIAMEN                18.0  \n",
       "XICHANG_GSN         1599.0  \n",
       "ZHENGZHOU_GSN        111.0  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2015rain = df[(df.YEAR==2015) & (df.ELEMENT==\"PRCP\")].groupby(\"NAME\").mean()\n",
    "df2015rain.head(30)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们发现NAME列不见了，因为它是做分组时候的索引，我们需要将索引名还原就能得到NAME。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>NAME</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>MONTH</th>\n",
       "      <th>DAY</th>\n",
       "      <th>VALUE</th>\n",
       "      <th>LATITUDE</th>\n",
       "      <th>LONGITUDE</th>\n",
       "      <th>ELEVATION</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>BEIJING_GSN</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>5.050000</td>\n",
       "      <td>15.600000</td>\n",
       "      <td>4.563333</td>\n",
       "      <td>39.933</td>\n",
       "      <td>116.283</td>\n",
       "      <td>55.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>BENXI</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.303371</td>\n",
       "      <td>15.359551</td>\n",
       "      <td>5.904494</td>\n",
       "      <td>41.317</td>\n",
       "      <td>123.783</td>\n",
       "      <td>185.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CHANGCHUN</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.113924</td>\n",
       "      <td>14.797468</td>\n",
       "      <td>5.591139</td>\n",
       "      <td>43.900</td>\n",
       "      <td>125.217</td>\n",
       "      <td>238.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>CHONGQING</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.273504</td>\n",
       "      <td>15.393162</td>\n",
       "      <td>6.730769</td>\n",
       "      <td>29.583</td>\n",
       "      <td>106.467</td>\n",
       "      <td>416.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>DALIAN</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.166667</td>\n",
       "      <td>15.916667</td>\n",
       "      <td>3.523611</td>\n",
       "      <td>38.900</td>\n",
       "      <td>121.633</td>\n",
       "      <td>97.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>FUZHOU</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>3.873950</td>\n",
       "      <td>15.310924</td>\n",
       "      <td>7.430252</td>\n",
       "      <td>26.083</td>\n",
       "      <td>119.283</td>\n",
       "      <td>14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>GUANGZHOU_GSN</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.482759</td>\n",
       "      <td>15.336207</td>\n",
       "      <td>15.381034</td>\n",
       "      <td>23.217</td>\n",
       "      <td>113.483</td>\n",
       "      <td>71.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>HAIKOU_GSN</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.702128</td>\n",
       "      <td>14.882979</td>\n",
       "      <td>8.646809</td>\n",
       "      <td>20.000</td>\n",
       "      <td>110.250</td>\n",
       "      <td>24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>HANGZHOU</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.200000</td>\n",
       "      <td>15.200000</td>\n",
       "      <td>12.049231</td>\n",
       "      <td>30.233</td>\n",
       "      <td>120.167</td>\n",
       "      <td>43.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>HARBIN</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>4.488095</td>\n",
       "      <td>15.380952</td>\n",
       "      <td>4.359524</td>\n",
       "      <td>45.750</td>\n",
       "      <td>126.767</td>\n",
       "      <td>143.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            NAME    YEAR     MONTH        DAY      VALUE  LATITUDE  LONGITUDE  \\\n",
       "0    BEIJING_GSN  2015.0  5.050000  15.600000   4.563333    39.933    116.283   \n",
       "1          BENXI  2015.0  4.303371  15.359551   5.904494    41.317    123.783   \n",
       "2      CHANGCHUN  2015.0  4.113924  14.797468   5.591139    43.900    125.217   \n",
       "3      CHONGQING  2015.0  4.273504  15.393162   6.730769    29.583    106.467   \n",
       "4         DALIAN  2015.0  4.166667  15.916667   3.523611    38.900    121.633   \n",
       "5         FUZHOU  2015.0  3.873950  15.310924   7.430252    26.083    119.283   \n",
       "6  GUANGZHOU_GSN  2015.0  4.482759  15.336207  15.381034    23.217    113.483   \n",
       "7     HAIKOU_GSN  2015.0  4.702128  14.882979   8.646809    20.000    110.250   \n",
       "8       HANGZHOU  2015.0  4.200000  15.200000  12.049231    30.233    120.167   \n",
       "9         HARBIN  2015.0  4.488095  15.380952   4.359524    45.750    126.767   \n",
       "\n",
       "   ELEVATION  \n",
       "0       55.0  \n",
       "1      185.0  \n",
       "2      238.0  \n",
       "3      416.0  \n",
       "4       97.0  \n",
       "5       14.0  \n",
       "6       71.0  \n",
       "7       24.0  \n",
       "8       43.0  \n",
       "9      143.0  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2015rain = df2015rain.reset_index()\n",
    "df2015rain.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 绘制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "lon_list = df2015rain.LONGITUDE.values\n",
    "lat_list = df2015rain.LATITUDE.values\n",
    "name_list = df2015rain.NAME.values\n",
    "val_list = df2015rain.VALUE.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"200592d0e5cf4f599909072f29bc05ee\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_200592d0e5cf4f599909072f29bc05ee = echarts.init(\n",
       "                    document.getElementById('200592d0e5cf4f599909072f29bc05ee'), 'white', {renderer: 'canvas'});\n",
       "                var option_200592d0e5cf4f599909072f29bc05ee = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"coordinateSystem\": \"geo\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"BEIJING_GSN\",\n",
       "                    \"value\": [\n",
       "                        116.2830000000001,\n",
       "                        39.933,\n",
       "                        4.5633333333333335\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"BENXI\",\n",
       "                    \"value\": [\n",
       "                        123.78299999999996,\n",
       "                        41.317,\n",
       "                        5.904494382022473\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"CHANGCHUN\",\n",
       "                    \"value\": [\n",
       "                        125.21699999999997,\n",
       "                        43.900000000000055,\n",
       "                        5.591139240506331\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"CHONGQING\",\n",
       "                    \"value\": [\n",
       "                        106.4670000000001,\n",
       "                        29.583000000000055,\n",
       "                        6.73076923076923\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"DALIAN\",\n",
       "                    \"value\": [\n",
       "                        121.63299999999987,\n",
       "                        38.900000000000055,\n",
       "                        3.5236111111111126\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"FUZHOU\",\n",
       "                    \"value\": [\n",
       "                        119.28299999999984,\n",
       "                        26.08300000000005,\n",
       "                        7.430252100840334\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"GUANGZHOU_GSN\",\n",
       "                    \"value\": [\n",
       "                        113.48300000000013,\n",
       "                        23.217000000000056,\n",
       "                        15.381034482758624\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"HAIKOU_GSN\",\n",
       "                    \"value\": [\n",
       "                        110.25,\n",
       "                        20.0,\n",
       "                        8.646808510638298\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"HANGZHOU\",\n",
       "                    \"value\": [\n",
       "                        120.16699999999983,\n",
       "                        30.23300000000006,\n",
       "                        12.049230769230766\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"HARBIN\",\n",
       "                    \"value\": [\n",
       "                        126.76699999999987,\n",
       "                        45.75,\n",
       "                        4.359523809523812\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"HEFEI\",\n",
       "                    \"value\": [\n",
       "                        117.23300000000015,\n",
       "                        31.867000000000065,\n",
       "                        9.288596491228066\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"JINAN\",\n",
       "                    \"value\": [\n",
       "                        117.05000000000013,\n",
       "                        36.599999999999966,\n",
       "                        5.7086206896551746\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"JINZHOU\",\n",
       "                    \"value\": [\n",
       "                        121.11700000000012,\n",
       "                        41.13300000000001,\n",
       "                        5.07924528301887\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"KUNMING\",\n",
       "                    \"value\": [\n",
       "                        102.68299999999999,\n",
       "                        25.01700000000004,\n",
       "                        8.771621621621623\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"NANCHANG_GSN\",\n",
       "                    \"value\": [\n",
       "                        115.91699999999982,\n",
       "                        28.599999999999937,\n",
       "                        13.021323529411763\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"NANJING\",\n",
       "                    \"value\": [\n",
       "                        118.89999999999976,\n",
       "                        31.932999999999996,\n",
       "                        14.614159292035398\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"NANNING_GSN\",\n",
       "                    \"value\": [\n",
       "                        108.21700000000006,\n",
       "                        22.632999999999996,\n",
       "                        5.9371428571428595\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"SANYA\",\n",
       "                    \"value\": [\n",
       "                        109.58299999999986,\n",
       "                        18.21700000000001,\n",
       "                        10.168055555555558\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"SHANGHAI_GSN\",\n",
       "                    \"value\": [\n",
       "                        121.46700000000014,\n",
       "                        31.40000000000006,\n",
       "                        10.948275862068964\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"SHIJIAZHUANG\",\n",
       "                    \"value\": [\n",
       "                        114.41700000000002,\n",
       "                        38.032999999999966,\n",
       "                        4.422727272727274\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"TAIYUAN\",\n",
       "                    \"value\": [\n",
       "                        112.5500000000001,\n",
       "                        37.78299999999996,\n",
       "                        2.9206896551724135\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"TIANJIN\",\n",
       "                    \"value\": [\n",
       "                        117.16700000000007,\n",
       "                        39.099999999999966,\n",
       "                        5.710416666666667\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"WUHAN\",\n",
       "                    \"value\": [\n",
       "                        114.04999999999984,\n",
       "                        30.59999999999994,\n",
       "                        11.397272727272721\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"WU_LU_MU_QI_GSN\",\n",
       "                    \"value\": [\n",
       "                        87.64999999999996,\n",
       "                        43.80000000000002,\n",
       "                        5.788709677419355\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"XIAMEN\",\n",
       "                    \"value\": [\n",
       "                        118.08300000000001,\n",
       "                        24.482999999999983,\n",
       "                        6.852688172043006\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"XICHANG_GSN\",\n",
       "                    \"value\": [\n",
       "                        102.26699999999988,\n",
       "                        27.900000000000038,\n",
       "                        6.221052631578949\n",
       "                    ]\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"ZHENGZHOU_GSN\",\n",
       "                    \"value\": [\n",
       "                        113.6499999999999,\n",
       "                        34.71700000000004,\n",
       "                        7.713793103448277\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"formatter\": function (params) {        return params.name + ' : ' + params.value[2];    },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Average Precipitation in 2015 (/cm)\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 20,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#50a3ba\",\n",
       "                \"#eac763\",\n",
       "                \"#d94e5d\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"geo\": {\n",
       "        \"map\": \"china\",\n",
       "        \"roam\": true,\n",
       "        \"aspectScale\": 0.75,\n",
       "        \"nameProperty\": \"name\",\n",
       "        \"selectedMode\": false,\n",
       "        \"emphasis\": {}\n",
       "    }\n",
       "};\n",
       "                chart_200592d0e5cf4f599909072f29bc05ee.setOption(option_200592d0e5cf4f599909072f29bc05ee);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7fe07b3faa20>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Geo\n",
    "from pyecharts.globals import ChartType\n",
    "geo = Geo()\n",
    "\n",
    "geo.add_schema(maptype=\"china\")\n",
    "\n",
    "for i in range(len(lat_list)):\n",
    "    geo.add_coordinate(name_list[i], lon_list[i], lat_list[i])\n",
    "\n",
    "geo.add(\"\", [(name_list[i], val_list[i]) for i in range(len(lat_list))], symbol_size=10)\n",
    "\n",
    "geo.set_series_opts(label_opts = opts.LabelOpts(is_show=False))\n",
    "\n",
    "geo.set_global_opts(visualmap_opts=opts.VisualMapOpts(max_ = 20), \n",
    "                    title_opts=opts.TitleOpts(title = 'Average Precipitation in 2015 (/cm)'))\n",
    "\n",
    "geo.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 自定义颜色和文本大小"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "geo = Geo()\n",
    "\n",
    "geo.add_schema(maptype=\"china\")\n",
    "\n",
    "for i in range(len(lat_list)):\n",
    "    geo.add_coordinate(name_list[i], lon_list[i], lat_list[i])\n",
    "\n",
    "geo.add(\"\", [(name_list[i], val_list[i]) for i in range(len(lat_list))], symbol_size=20)\n",
    "\n",
    "geo.set_series_opts(label_opts = opts.LabelOpts(is_show=False))\n",
    "\n",
    "geo.set_global_opts(visualmap_opts=opts.VisualMapOpts(max_ = 20), \n",
    "                    title_opts=opts.TitleOpts(pos_left='center',\n",
    "                                              title = 'Average Precipitation in 2015 (/cm)', \n",
    "                                              title_textstyle_opts=opts.TextStyleOpts(color='blue')\n",
    "                                             )\n",
    "                   )\n",
    "\n",
    "geo.render_notebook()\n"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "nbTranslate": {
   "displayLangs": [
    "*"
   ],
   "hotkey": "alt-t",
   "langInMainMenu": true,
   "sourceLang": "en",
   "targetLang": "fr",
   "useGoogleTranslate": true
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
